﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Baza.EF.DAL;

namespace Baza.EF.BLL
{
    
        public class DAKorisnici
        {
            public static List<Roles> RolesSelect()
            {

                return Connection.dm.sp_AdriaDay_Roles_SellectAll().ToList();

            }

            //public static void InsertUser(Users users, List<Roles> roles)
            //{

            //   int userID = Convert.ToInt32(Connection.DM.sp_AdriaDay_Users_Insert(users.FirstName, users.LastName, users.Email, users.PasswordHash, users.PasswordSalt, users.UserName).First());


            //   foreach (Roles r in roles)
            //   {
            //       Connection.DM.sp_AdriaDay_Users_Roles_Insert(userID, r.RoleID);

            //   }

            //}


            //public static Users SelectByUserName(string userName, string password)
            //{

            //    Baza.EF.DAL.Users user = Connection.dm.sp_AdriaDay_Users_SelectByUserName(userName).FirstOrDefault();

            //    if (user != null)
            //    {

            //        if (Baza.EF.DAL.UIHelper.GenerateHash(password, user.PasswordSalt) == user.PasswordHash)
            //        {
            //            user. = Connection.dm.sp_AdriaDay_UsersRoles_SelectByUser(user.UserID).ToList();
            //        }



            //    }

            //    return user;

            //}


            public static void InsertCustomer(Customers customer)
            {

                Connection.dm.sp_AdriaDay_Customers_Insert(customer.FirstName, customer.LastName, customer.Email, customer.PasswordHash, customer.PasswordSalt);
            }




            public static List<Customers> SelectBYCustomerID(int CustomerID)
            {

                return Connection.dm.sp_AdriaDay_Customers_Select_BY_ID(CustomerID).ToList();

            }


            public static void RemoveBYCustomerID(int CustomerID)
            {

                Connection.dm.sp_AdriaDay_Customers_Remove_BY_ID(CustomerID);

            }

            public static List<Customers> SelectAllCustomers()
            {

                return Connection.dm.sp_AdriaDay_Customers_SellectAll().ToList();

            }


            public static void UpdateCustomer(Customers customer)
            {

                Connection.dm.sp_AdriaDay_Customers_Update(customer.CustomerID, customer.FirstName, customer.LastName, customer.Email, customer.PasswordHash, customer.PasswordSalt, customer.Status);

            }

        }
    }

